//
//  GMTouchIDViewController.m
//  gentleman
//
//  Created by 范月成 on 2017/12/22.
//  Copyright © 2017年 fancy. All rights reserved.
//

#import "GMTouchIDViewController.h"

@interface GMTouchIDViewController ()

@property (nonatomic, strong) UIButton *touchButton;

@end

@implementation GMTouchIDViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self unlockWithTouchID];
}

- (void)initSubviews {
    [super initSubviews];
    
    [self.view addSubview:self.touchButton];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    self.touchButton.bounds = CGRectMake(0, 0, 100, 100);
    self.touchButton.center = self.view.center;
}

- (void)unlockWithTouchID {
    [[GMProtectTool shareTool] showTouchID:^(GMProtectStatus status) {
        if (status == GMProtectStatusSuccess) {
            [self dismissViewControllerAnimated:YES completion:nil];
        }
    }];
}

#pragma mark - get
- (UIButton *)touchButton {
    if (!_touchButton) {
        _touchButton =[[UIButton alloc] init];
        [_touchButton setImage:kImage(@"touchID") forState:UIControlStateNormal];
        [_touchButton addTarget:self action:@selector(unlockWithTouchID) forControlEvents:UIControlEventTouchDown];
    }
    return _touchButton;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
